/*
*
* MMUI
*
* this class creates a button to toggle the max/min mode
*
*/
class MMUI {
  
  // --------------------------------------
  // attributes
  // --------------------------------------
  ControlP5 controlP5;
  PApplet parent;
  int origX;
  int origY;
  int wid;
  int hei;
  Button mmButton;
  
  // ---------------------------------------
  // constructor
  // ---------------------------------------
  MMUI(ControlP5 cp5, PApplet p55, int x, int y, int w, int h) {
    
    // assign attributes
    controlP5 = cp5;
    parent = p55;
    origX = x;
    origY = y;
    wid = w;
    hei = h;
    
    // create button
    mmButton = controlP5.addButton("Scale: relative", 0, origX, origY, wid, hei);
    mmButton.setId(3);
    mmButton.hide();
    mmButton.setColorCaptionLabel(color(0));
    mmButton.setColorBackground(color(175, 200));
    //mmButton.setColorActive(color(0, 200, 200, 30));
    mmButton.setColorForeground(color(0, 200, 200, 30));                        // colour when mouse is overtop of item
    mmButton.setColorActive(color(0, 200, 200, 70));                            // colour when item is clicked

    
    
  } // constructor
  
  // ---------------------------------------
  // draw
  // ---------------------------------------
  void draw() {
    
    mmButton.show();
    
  } // draw
  
  // ---------------------------------------
  // switchMMMode
  // takes switches max/min mode of DModeManager passed
  // as argument
  // ---------------------------------------
  void switchMMMode(DModeManager dmm) {
    
    // switch drawing mode
    dmm.switchMMMode();
    
    // change button name
    if(dmm.maxMode == 0) {
      this.mmButton.setLabel("Scale: relative");
    } else {
      this.mmButton.setLabel("Scale: absolute");
    } // if
    
  } // switchMMode
  
} // MMUI
